/**
 * 
 */
package de.mbenning.fsim.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * @author Martin.Benning
 *
 */
@Entity
@Table (name = "SPIELTAG")
public class Spieltag {

	@Id
	@GeneratedValue (strategy = GenerationType.TABLE)
	@Column (name  = "ID", updatable = false, nullable = false)
	private Integer id;
	
	@Column(name = "DATUM_VON")
	private Date datumVon;
	
	@Column(name = "DATUM_BIS")
	private Date datumBis;
	
	@Column
	private int nummer;
	
	@ManyToOne (fetch = FetchType.EAGER)
	@JoinColumn (name = "SPIELPLAN_ID")
	private Spielplan spielplan;
	
	@OneToMany(cascade = CascadeType.ALL, targetEntity = Paarung.class, fetch = FetchType.EAGER)
	@JoinColumn(name = "SPIELTAG_ID", insertable = true, updatable = true)
	@Fetch(FetchMode.SELECT)
	private List<Paarung> paarungen = new ArrayList<Paarung>();
	
	public Spieltag() {
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Date getDatumVon() {
		return datumVon;
	}

	public void setDatumVon(Date datumVon) {
		this.datumVon = datumVon;
	}

	public Date getDatumBis() {
		return datumBis;
	}

	public void setDatumBis(Date datumBis) {
		this.datumBis = datumBis;
	}

	public int getNummer() {
		return nummer;
	}

	public void setNummer(int nummer) {
		this.nummer = nummer;
	}

	public Spielplan getSpielplan() {
		return spielplan;
	}

	public void setSpielplan(Spielplan spielplan) {
		this.spielplan = spielplan;
	}

	public List<Paarung> getPaarungen() {
		return paarungen;
	}

	public void setPaarungen(List<Paarung> paarungen) {
		this.paarungen = paarungen;
	}
}
